#include "queueB.h"
// 初始化
void initB(QueueB *q) { q->head = q->tail = q->size = 0; }

// 判空
bool isEmptyB(QueueB *q) { return q->size == 0; }

// 判满
bool isFullB(QueueB *q) { return q->size == CAPACITY; }

// 入队
bool enqueueB(QueueB *q, int x) {
  if (isFullB(q))
    return false;
  q->data[q->tail] = x;
  q->tail = (q->tail + 1) % CAPACITY;
  q->size++;
  return true;
}

// 出队
bool dequeueB(QueueB *q, int *x) {
  if (isEmptyB(q))
    return false;
  *x = q->data[q->head];
  q->head = (q->head + 1) % CAPACITY;
  q->size--;
  return true;
}